package com.kaoshidian.front.mongodb;

import com.kaoshidian.front.mongodb.base.BaseManage;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;

public class MyCourseManager extends BaseManage {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		MyCourseManager manager = new MyCourseManager();
		manager.mainBody("MyCourse");
	}

	@Override
	public void treate(DBCollection coll) {
		DBCursor cur = coll.find();
		while (cur.hasNext()) {
			DBObject cool = cur.next();
			DBObject critique = (DBObject) cool.get("critique");
			if (critique != null) {
				if (critique.containsField("commentState")) {
					critique.removeField("commentState");
				}
				{
					String signtopItem = (String) critique.get("signtop");
					if (signtopItem.equals("COMMON")) {
						critique.put("signtop", "UN_SIGNTOP");
					}
					String coolItem = (String) critique.get("cool");
					if (coolItem.equals("COMMON")) {
						critique.put("cool", "UN_COOL");
					}
					String recommendItem = (String) critique.get("recommend");
					if (recommendItem.equals("NO_RECOMMEND")) {
						critique.put("recommend", "UN_RECOMMEND");
					}
				}
				coll.save(cool);
			}
		}

	}

}
